import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators';

// import type {Visitor as VisitorType} from '@/models/visitor'
import { HeaderCover } from 'src/models/headCover';

@Module<HeaderCover>({
  stateFactory: true,
  namespaced: true
})
export default class HeaderCoverStateModule extends VuexModule {
  value: HeaderCover = {
    //滚动条距离顶部距离
    visible: false,

    //背景图片
    bgImg: '',

    //标题
    title: '',

    subTitle: '',

    useSlot: false,

    slotContent: '',

    showArrow: false
  };

  @Mutation
  INIT(val: HeaderCover) {
    this.value = val;
  }

  //重置Header封面
  @Mutation
  RESET() {
    this.value.visible = false;
    this.value.bgImg = '';
    this.value.title = '';
    this.value.subTitle = '';
    this.value.useSlot = false;
    this.value.slotContent = '';
    this.value.showArrow = false;
  }

  @Action({ rawError: true })
  async Init(params: HeaderCover) {
    this.context.commit('INIT', params);
  }

  @Action({ rawError: true })
  async Reset() {
    this.context.commit('RESET');
  }
}
